<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function addThree(num) {
        var arr = [];

        for (let i = 1; i <= 100; i++) {
          if (i % num == 0) {
            arr.push(i);
          }
        }
        var sum = arr.reduce((acc, cur) => {
          return acc + cur;
        }, 0);
        return console.log(`被${num}整除的数有${arr},总和${sum}`);
      }

      addThree(3);
      addThree(5);
      addThree(6);
      addThree(8);
    </script>
  </body>
</html>
